package com.dg.gaming.server;

import java.util.concurrent.*;

import com.dg.gaming.server.messages.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2009</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class WorkerQueue {
    ThreadPoolExecutor executor = null;
    boolean alive;

    public WorkerQueue(ThreadPoolExecutor executor) {
        this.executor = executor;
        alive = true;

    }

    public void addMessage(AUserMessage usermassage) {
        if (isAlive()) {
            AUserMessage message = usermassage;
            Worker worker = new Worker(this, message);
            executor.execute(worker);

        }

    }

    public boolean isAlive() {
        return alive;
    }

    public void setAlive(boolean alive) {
        this.alive = alive;
        if (alive) {
            return;

        }
    }


}
